#include<vector>
using namespace std;

bool vis1[200][200], vis2[200][200];
int m, n;
int dx[4] = { 0, 0, 1, -1 };
int dy[4] = { 1, -1, 0, 0 };
void dfs1(vector<vector<int>>& heights, int i, int j)
{
    for (int k = 0; k < 4; k++)
    {
        int x = i + dx[k], y = j + dy[k];
        if (x >= 0 && x < m && y >= 0 && y < n && !vis1[x][y] && heights[i][j] <= heights[x][y])
        {
            vis1[x][y] = true;
            dfs1(heights, x, y);
        }
    }
}
void dfs2(vector<vector<int>>& heights, int i, int j)
{
    for (int k = 0; k < 4; k++)
    {
        int x = i + dx[k], y = j + dy[k];
        if (x >= 0 && x < m && y >= 0 && y < n && !vis2[x][y] && heights[i][j] <= heights[x][y])
        {
            vis2[x][y] = true;
            dfs2(heights, x, y);
        }
    }
}
vector<vector<int>> pacificAtlantic(vector<vector<int>>& heights) {
    m = heights.size(), n = heights[0].size();
    for (int i = 0; i < m; i++)
    {
        if (!vis1[i][0])
        {
            vis1[i][0] = true;
            dfs1(heights, i, 0);
        }
    }
    for (int j = 0; j < n; j++)
    {
        if (!vis1[0][j])
        {
            vis1[0][j] = true;
            dfs1(heights, 0, j);
        }
    }
    for (int i = 0; i < m; i++)
    {
        if (!vis2[i][n - 1])
        {
            vis2[i][n - 1] = true;
            dfs2(heights, i, n - 1);
        }
    }
    for (int j = 0; j < n; j++)
    {
        if (!vis2[m - 1][j])
        {
            vis2[m - 1][j] = true;
            dfs2(heights, m - 1, j);
        }
    }
    vector<vector<int>> ret;
    for (int i = 0; i < m; i++)
    {
        for (int j = 0; j < n; j++)
        {
            if (vis1[i][j] && vis2[i][j])
            {
                ret.push_back(vector<int>());
                ret.back().push_back(i);
                ret.back().push_back(j);
            }
        }
    }
    return ret;
}

int main()
{


    return 0;
}